fileclassification
Class FileClassification

java.lang.Object
  extended by fileclassification.FileClassification

public class FileClassification
extends java.lang.Object


Constructor Summary
FileClassification()
           
 
Method Summary
static void createFile(java.lang.String fileName)
          Creates file.
static java.lang.String exportPDF(java.lang.String directory, java.lang.String name)
          When the PDF structure is recognized, returns string with exported textual data of a PDF file.
static java.lang.String exportXML(java.lang.String directory, java.lang.String file)
          Returns string with exported textual data of a PDF file.
static void inDirectory(java.io.File directory, java.lang.String saveDirectory, int choice)
          Saves and prints occurrences of features of all files in one table.
static int[] loadDOCX(java.lang.String directory, java.lang.String file)
          Returns an array of occurrences of features that belong to DOCX file.
static int[] loadODT(java.lang.String directory, java.lang.String name)
          Returns an array of occurrences of features that belong to DOCX file.
static int[] loadPDF(java.lang.String directory, java.lang.String file)
          Returns an array of occurrences of each PDF object.
static void main(java.lang.String[] args)
          In this main method is programmed logic of the whole application.
static void saveFile(java.lang.String text, java.lang.String directory, java.lang.String name)
          Saves given textual data to the .txt file.
static boolean testDOCX(int[] loadedDOCX, java.lang.String name)
          Returns "false" in case that given file does not contain the DOCX structure, returns "true" when file is automatically recognized as DOCX file.
static boolean testODT(int[] loadedODT, java.lang.String name)
          Returns "false" in case that given file does not contain the ODT structure, returns "true" when file is automatically recognized as ODT file.
static boolean testPDF(int[] loadedPDF, java.lang.String name)
          Returns "false" in case that given file does not contain the PDF structure, returns "true" when file is automatically recognized as PDF.
static boolean testSingleDOCX(java.lang.String directory, java.lang.String name)
          Returns "false" in case that given file does not contain the DOCX structure, returns "true" when file is automatically recognized as DOCX.
static boolean testSingleODT(java.lang.String directory, java.lang.String name)
          Returns "false" in case that given file does not contain the ODT structure, returns "true" when file is automatically recognized as ODT.
static boolean testSinglePDF(java.lang.String directory, java.lang.String name)
          Returns "false" in case that given file does not contain the PDF structure, returns "true" when file is automatically recognized as PDF.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileClassification

public FileClassification()
Method Detail

testSinglePDF

public static boolean testSinglePDF(java.lang.String directory,
                                    java.lang.String name)
Returns "false" in case that given file does not contain the PDF structure, returns "true" when file is automatically recognized as PDF.

Parameters:
directory - an absolute path of directory
name - the name of the file within directory
Returns:
true or false

loadPDF

public static int[] loadPDF(java.lang.String directory,
                            java.lang.String file)
Returns an array of occurrences of each PDF object. Objects are in order: Name, object, obj, endobj, stream, endstream, xref, startx, trailer, page, encrypt, objStm, JS, javaS, AA, openA, acroF, jbig2, richM, launch, filter, flateD, Length, Number of chars

Parameters:
directory - an absolute path of directory
file - the name of the file within directory
Returns:
array of objects

testPDF

public static boolean testPDF(int[] loadedPDF,
                              java.lang.String name)
Returns "false" in case that given file does not contain the PDF structure, returns "true" when file is automatically recognized as PDF.

Parameters:
loadedPDF - array containing occurrences of objects
name - the name of given file
Returns:
true or false

exportPDF

public static java.lang.String exportPDF(java.lang.String directory,
                                         java.lang.String name)
When the PDF structure is recognized, returns string with exported textual data of a PDF file.

The textual data within the string are encoded and may contain images. In most cases it is encoded by one of these algorithms: FlateDecode, ASCIIHexDecode, JBIG2Decode, etc. In return string you can find tags witch represent determine algorithm for text decoding.

Parameters:
directory - an absolute path of directory
name - the name of the file within directory
Returns:
the string of exported textual data from the PDF file

testSingleDOCX

public static boolean testSingleDOCX(java.lang.String directory,
                                     java.lang.String name)
Returns "false" in case that given file does not contain the DOCX structure, returns "true" when file is automatically recognized as DOCX.

Parameters:
directory - an absolute path of directory
name - the name of the file within directory
Returns:
true or false

loadDOCX

public static int[] loadDOCX(java.lang.String directory,
                             java.lang.String file)
Returns an array of occurrences of features that belong to DOCX file. Features are in order: Name, object, [Content_Types].xml, _rels/.rels, word/_rels/document.xml.rels, word/document.xml, word/media, word/theme, docProps, word/embeddings, word/settings.xml, word/webSettings.xml, word/styles.xml, word/fontTable.xml

Parameters:
directory - an absolute path of directory
file - the name of the file within directory
Returns:
array of objects

testDOCX

public static boolean testDOCX(int[] loadedDOCX,
                               java.lang.String name)
Returns "false" in case that given file does not contain the DOCX structure, returns "true" when file is automatically recognized as DOCX file.

Parameters:
loadedDOCX - array containing occurrences of objectss
name - the name of given file
Returns:
true or false

exportXML

public static java.lang.String exportXML(java.lang.String directory,
                                         java.lang.String file)
Returns string with exported textual data of a PDF file.

The textual data within the DOCX file are compressed in one ZIP packet. If file contains textual data in ZIP packet is corrupted is not able to export textual data.

This method works for both XML-based office files (DOCX, ODT).

Parameters:
directory - an absolute path of given directory
file - the name of the file within directory
Returns:
the string of exported textual data from the XML-based office file

testSingleODT

public static boolean testSingleODT(java.lang.String directory,
                                    java.lang.String name)
Returns "false" in case that given file does not contain the ODT structure, returns "true" when file is automatically recognized as ODT.

Parameters:
directory - an absolute path of directory
name - the name of the file within directory
Returns:
true or false

loadODT

public static int[] loadODT(java.lang.String directory,
                            java.lang.String name)
Returns an array of occurrences of features that belong to DOCX file. Features are in order: Name, objects, manifest.xml, thumbnail.png, content.xml, layout-cache, manifest.rdf, meta.xml, mimetype, settings.xml, styles

Parameters:
directory - an absolute path of directory
name - the name of the file within directory
Returns:
array of objects

testODT

public static boolean testODT(int[] loadedODT,
                              java.lang.String name)
Returns "false" in case that given file does not contain the ODT structure, returns "true" when file is automatically recognized as ODT file.

Parameters:
loadedODT - array containing occurrences of objectss
name - the name of given file
Returns:
true or false

inDirectory

public static void inDirectory(java.io.File directory,
                               java.lang.String saveDirectory,
                               int choice)
Saves and prints occurrences of features of all files in one table. Save file is named table.txt.

Parameters:
directory - an absolute path of given directory
saveDirectory - an absolute path to save table containing occurrences of features of file
choice - represents which file structure should be tested: 1. PDF, 2. DOCX, 3. ODT

createFile

public static void createFile(java.lang.String fileName)
Creates file.

Parameters:
fileName - name of created file

saveFile

public static void saveFile(java.lang.String text,
                            java.lang.String directory,
                            java.lang.String name)
Saves given textual data to the .txt file.

Parameters:
text - given textual data
directory - an absolute path to save file
name - name of save file

main

public static void main(java.lang.String[] args)
In this main method is programmed logic of the whole application. Selected methods are called by the given arguments.

For run application is required insert arguments.

Type of argument for analyze all files in directory:
PDF - testFilesPDF
DOCX - testFilesDOCX
ODT - testFilesODT

for analyze single file:
PDF - singlePDF
DOCX - singleDOCX
ODT - singleODT

Parameters:
args - [0] = given directory, [1] = save directory, [2] = choice